using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMRemitos
    {
        public BMRemitos(string coneccion)
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        private Remitos oRemitos = new Remitos();
        private List<Remitos> listaRemitos = new List<Remitos>();
        private DARemitos daRemitos = new DARemitos();

        #region BMRemitosSearch
        public List<Remitos> BMRemitosSearch(Remitos remitoD, Remitos remitoH)
        {
            try
            {
                listaRemitos = daRemitos.DAremitosSearch(connection, remitoD, remitoH);
                return listaRemitos;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRemitosInsert
        public void BMRemitosInsert(Remitos remito)
        {
            try
            {
                daRemitos.DARemitosInsert(connection, remito);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRemitosUpdate
        public void BMRemitosUpdate(Remitos remito)
        {
            try
            {
                daRemitos.DARemitosUpdate(connection, remito);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRemitosUpdateEstado
        public void BMRemitosUpdateEstado(Remitos remito)
        {
            try
            {
                daRemitos.DaRemitosUpdateEstado(connection, remito);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRemitosGetNext
        public Remitos BMRemitosGetNext()
        {
            try
            {
                oRemitos = daRemitos.DARemitosGetNext(connection);
                return oRemitos;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}
